#include <iostream>
#include <string>
using namespace std;

int main(){
    string s;
    cin >> s;
    if (s.size() == 1){
        cout << 0 << endl;
        return 0;
    }
    int left = 0, right = s.size() - 1;
    bool flag = true;
    bool issame = true;
    while (right > left){
        if (s[right--] != s[left++]) {
            flag = false;
            break;
        }
        if (s[left] != s[left - 1]) issame = false;
    }
    if (flag){
        if (issame) cout << 0 << endl;
        else cout << s.size() - 1 << endl;
    }
    else 
        cout << s.size() << endl;
    return 0;
}